﻿define(['util', 'ajax'], function (util, ajax) {
    "use strict";

    var exports = {},
         ViewModel;

    ViewModel = function (data) {        
        var self = this;
        var detail = data.detail;
        
        var canvas = document.getElementById("imgCanvas");
        util.image.drawImage(canvas, util.image.checkOrDefault(detail.imageData));

        self.id = ko.observable(detail.id);
        self.name = ko.observable(detail.name);
        self.tags = ko.observable(detail.tags);
        self.description = ko.observable(detail.description);
        self.imageData = ko.observable(detail.imageData);
        
        self.accountId = ko.observable(detail.referenceId);
        self.accountName = ko.observable(detail.referenceName);
    };

    exports.exec = function (sectionId, model) {
        var viewModel = new ViewModel(model);
        ko.applyBindings(viewModel, document.getElementById(sectionId));
    };

    return exports;
});